/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.iti.jets.gpts.dto.assist;

import com.iti.jets.gpts.pojo.Point;
import com.iti.jets.gpts.pojo.TranService;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author mustafajnr
 */
public class TranServiceUsage {

    TranService tranService;
    Point target;
    Point destination;
    Integer distance;

    TranServiceUsage(String group) {
        Pattern pattern = Pattern.compile("\\d+");
        Matcher matcher = pattern.matcher(group);
        matcher.find();
        tranService = Business.getTranService(Integer.parseInt(matcher.group()));
        matcher.find();
        target = Business.getPoint(Integer.parseInt(matcher.group()));
        matcher.find();
        destination = Business.getPoint(Integer.parseInt(matcher.group()));
        matcher.find();
        distance = Integer.parseInt(matcher.group());
    }

    @Override
    public String toString() {
        return "TranServiceUsage{" + "tranService=" + tranService + ", target=" + target + ", destination=" + destination + ", distance=" + distance + '}';
    }

    String toJSON() {
        return "{" + "tranService:" + tranService.toJSON() + ", target:\"" + target.toJSON() + "\", destination:\"" + destination.toJSON() + "\", distance:" + distance + '}';
    }

}
